(שינוי הכתובת אליה חוזרים עבור רשות התקשוב)
(הוספת hospitals.health.gov.il)
 
שורה 7: שורה 7:
 
'justice.gov.il', 'mse.gov.il', 'education.gov.il', 'cio.gov.il',
 
'justice.gov.il', 'mse.gov.il', 'education.gov.il', 'cio.gov.il',
 
'women.mse.gov.il', 'young.mse.gov.il', 'seniors.mse.gov.il',
 
'women.mse.gov.il', 'young.mse.gov.il', 'seniors.mse.gov.il',
'minorities.mse.gov.il', 'digitalisrael.mse.gov.il', 'ceo.mse.gov.il'
+
'minorities.mse.gov.il', 'digitalisrael.mse.gov.il', 'ceo.mse.gov.il',
 +
'hospitals.health.gov.il'
 
],
 
],
 
perSourceSettings: {
 
perSourceSettings: {
שורה 59: שורה 60:
 
title: false,
 
title: false,
 
okButton: 'אני מאשר/ת'
 
okButton: 'אני מאשר/ת'
 +
},
 +
'hospitals.health.gov.il': {
 +
title: false,
 +
okButton: 'אני מאשר/ת',
 +
allowDoNotShowAgain: false
 
},
 
},
 
'cio.gov.il': {
 
'cio.gov.il': {

גרסה אחרונה מ־16:50, 10 בנובמבר 2019

/* Warning! Global gadget file! */
( function( $, mw ) {
	'use strict';
	mw.CityRights = {
		legitSources: [
			'hodhasharon', 'patientsrightssociety', 'health.gov.il',
			'justice.gov.il', 'mse.gov.il', 'education.gov.il', 'cio.gov.il',
			'women.mse.gov.il', 'young.mse.gov.il', 'seniors.mse.gov.il',
			'minorities.mse.gov.il', 'digitalisrael.mse.gov.il', 'ceo.mse.gov.il',
			'hospitals.health.gov.il'
		],
		perSourceSettings: {
			'justice.gov.il': {
				backTo: 'https://www.justice.gov.il/',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'mse.gov.il': {
				backTo: 'https://www.gov.il/he/Departments/ministry_for_social_equality',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'women.mse.gov.il': {
				backTo: 'https://www.gov.il/he/Departments/the_authority_for_the_advancement_of_the_status_of_women',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'young.mse.gov.il': {
				backTo: 'https://www.gov.il/he/departments/units/tzeirim',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'seniors.mse.gov.il': {
				backTo: 'https://www.gov.il/he/Departments/Topics/senior_citizens_subject',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'minorities.mse.gov.il': {
				backTo: 'https://www.gov.il/he/Departments/Units/minorities_shivyon',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'digitalisrael.mse.gov.il': {
				backTo: 'https://www.gov.il/he/Departments/digital_israel',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'ceo.mse.gov.il': {
				backTo: 'https://www.gov.il/he/Departments/ministry_for_social_equality',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'education.gov.il': {
				backTo: 'https://edu.gov.il/',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'health.gov.il': {
				backTo: 'https://www.health.gov.il/',
				title: false,
				okButton: 'אני מאשר/ת'
			},
			'hospitals.health.gov.il': {
				title: false,
				okButton: 'אני מאשר/ת',
				allowDoNotShowAgain: false
			},
			'cio.gov.il': {
				backTo: 'https://www.gov.il/he/Departments/technical_support_for_online_services',
				title: false,
				okButton: 'אני מאשר/ת',
				allowDoNotShowAgain: false
			}
		},
		cookieName: '_CityRightsNoShow',
		msgPrefix: 'MediaWiki:CityRights-welcome-',
		listNoShow: [],
		param: 'utm_source',
		source: '',
		settings: {
			backTo: false,
			title: 'ברוכים הבאים לכל-זכות!',
			okButton: 'סגור',
			allowDoNotShowAgain: true
		},

		showDialog: function( data ) {
			var sourceSettings = mw.CityRights.perSourceSettings[ mw.CityRights.source ];
			if( typeof( sourceSettings) === 'object' ) {
				$.extend( mw.CityRights.settings, sourceSettings );
			}

			var $dialog = mw.CityRights.createDialogElement( data.parse.text['*'] );

			$dialog.on( 'hide.bs.modal', function () {
				if ( mw.CityRights.settings.allowDoNotShowAgain === true ) {
					var doNotShowAgain = $dialog.find( '.dismiss-forever > input' ).prop( 'checked' );
					if( doNotShowAgain ) {
						mw.CityRights.listNoShow.push(mw.CityRights.source);
						mw.cookie.set(mw.CityRights.cookieName, mw.CityRights.listNoShow);
					}
				}
			});

			$dialog.on( 'shown.bs.modal', function () {
				$dialog.find( '.btn-default' ).focus();
			});

			$dialog.modal();
		},


		/*
		 * options.backTo: a url to send the user do if the dialog is declined. This turns into a yes/no confirmation
		 */
		createDialogElement: function( content ) {
			var backButton = '';
			if( mw.CityRights.settings.backTo ) {
				backButton = '<a class="backButton" href="' + mw.CityRights.settings.backTo + '">לא, תודה - קחו אותי לאתר הרשמי</a>';
			}
			var html = '<div class="modal modal-govt-welcome" data-backdrop="static" tabindex="-1" role="dialog">' +
				'<div class="modal-dialog" role="document">' +
				'<div class="modal-content">';

			if( mw.CityRights.settings.title ) {
				html += '<div class="modal-header">' +
					'<button type="button" class="close" data-dismiss="modal" aria-label="סגור"><span aria-hidden="true">&times;</span></button>' +
					'<h4 class="modal-title text-center">' + mw.CityRights.settings.title + '</h4>' +
					'</div>';
			}
			html += '<div class="modal-body">' + content + '</div>' +
				'<div class="modal-footer">' +
				'<button type="button" class="btn btn-default btn-lg" data-dismiss="modal">'+ mw.CityRights.settings.okButton + '</button>' +
				'<div class="form-inline modal-footer-extra-controls">';
			if( mw.CityRights.settings.allowDoNotShowAgain === true ) {
				html += '<label class="dismiss-forever checkbox">' +
					'<input type="checkbox"> <span>אל תציגו בעתיד</span>' +
					'</label>';
			}
			html += backButton +
				'</div>' +
				'</div>' +
				'</div><!-- /.modal-content --></div><!-- /.modal-dialog --></div>';

			return $(html);
		},

		welcome: function() {
			// Some defensive programming - make sure the ResourceLoader modules are ready
			mw.loader.using( ['mediawiki.util', 'mediawiki.cookie', 'mediawiki.api' ], function() {
				mw.CityRights.source =  mw.util.getParamValue( mw.CityRights.param );

				if( mw.CityRights.source === null || mw.CityRights.source === '' ) {
					return;
				}

				mw.CityRights.source = mw.CityRights.source.replace(/ /g,"").toLowerCase();
				if( $.inArray( mw.CityRights.source, mw.CityRights.legitSources ) < 0 ) {
					return;
				}

				var cookie = mw.cookie.get( mw.CityRights.cookieName );
				mw.CityRights.listNoShow = cookie ? cookie.split(',') : [];


				if( $.inArray( mw.CityRights.source, mw.CityRights.listNoShow ) > -1 ) { return; }

				var api = new mw.Api();
				api.get( {
					action: 'parse',
					prop: 'text',
					page: mw.CityRights.msgPrefix + mw.util.rawurlencode( mw.CityRights.source ),
					disablelimitreport: true

				} )
					.done ( mw.CityRights.showDialog )
					.fail( function( data ) {
						mw.log( "Message failed to load through the API: ", data );
					});
			} );
		}
	};

	mw.CityRights.welcome();

})( jQuery, mediaWiki );