PageSourceSearch

https://cpaa.co.uk/res/blogs/js/crop_model.js

js cpaa.co.uk collected 2026-10-08 02:30:01 UTC 3,066 bytes, 141 lines download raw bytes

1var mwCrop = {
2	
3	items_ids_list	: [], // array of ids to make img croppable
4	
5	init		: function() {
6		
7		var $this = this;
8		
9		//remove old images (for ajax load)
10		jQuery('.blogs-post-crop-icon').remove();
11		
12		jQuery.each(this.items_ids_list, function(i){
13			
14			//var $i = jQuery('#' + $this.items_ids_list[i]);
15			var $i = jQuery('[data-crop-sn=' + $this.items_ids_list[i] + ']');
16			//___($i);
17			var run_crop = function(e) {
18				
19				mwLiveEd.toggle(false);
20				mwLiveEd.noResize = true;
21				
22				var $ed = mwImgEd($i, {
23				//	'debug'		: true,
24					'zoomValue'	: 1,
25					'modal'		: true,
26					'overlay'	: false,
27					'resizeOn'	: 'y',
28				//	'resizeOn'	: false,
29				})
30				.onSave( function () {
31						
32						//___(this.queryStr);
33						//$this.Data.pwidth	= Math.round($this.Data.pwidth);
34						//$this.Data.ewidth	= Math.round(this.x.wrapSize);
35						//$this.Data.eheight	= Math.round(this.y.wrapSize);
36						
37						var $data = {};
38						
39						$data['id'] = $this.items_ids_list[i];
40						$data['crop'] = this.queryStr;
41						
42						mwAjax('/site/ajax/blogs/cropcontroller/saveCropDB', $data, false)
43							.go()
44							.success( function($data) {
45								
46								___('imged crop save done');
47								
48							} )
49							.error( function() {
50								
51								___('imged crop save error');	
52								
53							} )
54						; // mwAjax
55						
56					}
57				) //FUNC onSave
58				.onAfterSave( function () {
59	
60						// Finalizing dimensions
61						// ToDo: autodetect if necessary in imgEd
62						this.onResize();
63						
64						mwLiveEd.toggle(true);
65						mwLiveEd.noResize = false;
66						
67					}
68				) //FUNC onAfterSave
69				; // $ed
70				
71			};
72			
73			//check is current image local
74			var isLocal = false;
75			if ( $i.attr('src').indexOf('://') == -1 ) {
76				
77				//this is local url
78				isLocal = true;
79				
80			}
81			else {
82				
83				var url = new URL($i.attr('src'));
84				
85				//local url
86				if ( location.host == url.host )
87					isLocal = true;
88				
89			}
90			
91			//if local url
92			if ( isLocal ) {
93				
94				var btn = jQuery('<div class="blogs-post-crop-icon"></div>'); 
95				$i.before(btn);
96				btn.click(run_crop);
97				//setTimeout( function() { btn.css('left', $i.width() - 35); btn.css('top', 35); }, 100);
98				$i.load( function() { btn.css('left', $i.width() - 35); btn.css('top', 35); } );
99				
100				$i.off('dblclick').on('dblclick', run_crop);
101				
102			}
103			
104		});
105	},
106	
107	/** //** ----= add_items	=------------------------------------------------------------------------------\**//** \
108	*
109	*	Add ids of items to list
110	* 			
111	* 	@param	array	items	- items must be array of text ids
112	* 
113	*	@return	nothing
114	*
115	\**//** -------------------------------------------------------------------= by Alex @ Morad Media Inc. =------/** //**/
116	
117	add_items	: function(items) {
118		
119		jQuery.each(items, function(i){
120			
121			//___(this, i, items[i]);
122			
123			if ( mwCrop.items_ids_list.indexOf(items[i]) == -1 )
124				mwCrop.items_ids_list.push(items[i]);
125			
126		});
127	},
128	
129	
130	
131} // OBJ mwCrop
132
133jQuery( function () {
134	
135	if ( typeof mwData != "undefined" ) {
136		
137		mwCrop.init();
138		
139	}
140	
141});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.